define(['httpx'], function(httpx) {
	var app = Drv.getApp();
	var router = app.router;
	var params = router.$params;
	var user = "";
	var page = "signin";
	httpx.request({
		debug: false,
		async: false,
		timeout: 5000,
		url: "erp/index/check-login",
		method: "get",
		dataType: "json",
		data: {},
		success: function(data) {
			if(data.status == 200) {
				user = data.data;
				page = "index";
			} else {
				user = "";
			}
		},
		error: function(method, url) {},
		ontimeout: function(method, url) {}
	});
	var vmOptions = {
		el: "#layout",
		data: user,
		ready: function() { //在页面后加载
			//console.log("Vue.$http", this.$http);
			layui.config({
				base: 'js/cms/'
			});
			layui.use('form', function() {
				//监听提交
				layui.form().on('submit(signin)', function(data) {
					layer.msg(JSON.stringify(data.field));
					httpx.request({
						debug: false,
						async: false,
						timeout: 5000,
						url: "erp/index/login",
						method: "post",
						dataType: "json",
						data: data.field,
						success: function(data) {
							if(data.status == 200) {
								window.location.href = "/";
							} else {
								layui.msg("function");
							}
						},
						error: function(method, url) {},
						ontimeout: function(method, url) {}
					});
					return false;
				});
				//修正登录框margin
				var fieldset = layui.jquery("fieldset").eq(0);
				fieldset.css("margin-top", (layui.jquery(window).height() - fieldset.height()) * 0.3 + "px");
			});
		},
		methods: { //页面vue事件
			clickDiv: function(e) {
				//console.log(e.target);
				console.debug("this is a vue 2");
			}
		}
	};
	app.render(page, vmOptions);
});